package com.kumi.blog.discuss.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.kumi.blog.discuss.bean.Discuss;
import com.kumi.blog.discuss.service.DiscussService;
import com.kumi.common.utils.PageUtils;
import com.kumi.common.utils.R;



/**
 * 评论 
 *
 * @author kumi
 * @email 1971240051@qq.com
 * @date 2022-06-04 03:24:01
 */
@RestController
@RequestMapping("discuss/discuss")
public class DiscussController {
    @Autowired
    private DiscussService discussService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("discuss:discuss:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = discussService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{dId}")
    //@RequiresPermissions("discuss:discuss:info")
    public R info(@PathVariable("dId") Integer dId){
		Discuss discuss = discussService.getById(dId);

        return R.ok().put("discuss", discuss);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("discuss:discuss:save")
    public R save(@RequestBody Discuss discuss){
		discussService.save(discuss);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("discuss:discuss:update")
    public R update(@RequestBody Discuss discuss){
		discussService.updateById(discuss);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("discuss:discuss:delete")
    public R delete(@RequestBody Integer[] dIds){
		discussService.removeByIds(Arrays.asList(dIds));

        return R.ok();
    }

}
